/*------------------------------------------------------
                hou_elearningGEN beta v1.0
Author: xtrung.net@gmail.com
Write On: 04/27/2008
Create On:4/13/2012 11:22:59 AM
------------------------------------------------------*/
using hou_elearning.DataAccess.Base;
using hou_elearning.Entity;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Collections;
using System.Web;

namespace hou_elearning.DataAccess
{    
    public class Baihoc_SlideDAL : SqlProvider<Baihoc_SlideEntity>
    {
        static Baihoc_SlideDAL()
        {
            InitReader();
        }
        protected static void InitReader()
        {
            getFromReader=delegate(SqlDataReader dr)
            {
                Baihoc_SlideEntity entity = new Baihoc_SlideEntity();
				entity.PK_iBaihoc_SlideID = Int64.Parse("0"+dr["PK_iBaihoc_SlideID"].ToString());
				entity.FK_iBaihocID = Int64.Parse("0"+dr["FK_iBaihocID"].ToString());
				entity.FK_iSlideID = Int64.Parse("0"+dr["FK_iSlideID"].ToString());
                entity.iSothutu = short.Parse("0" + dr["iSothutu"].ToString());
                return entity;
            };
        }
        public static Baihoc_SlideEntity GetOne(Int64 PK_iBaihoc_SlideID)
        {
            string cmdName = "spBaihoc_Slide_GetByPK";
            SqlParameter p = new SqlParameter("@PK_iBaihoc_SlideID", PK_iBaihoc_SlideID);
            Baihoc_SlideEntity entity = GetOne(cmdName, p);
            return entity;
        }
        public static List<Baihoc_SlideEntity> GetAll()
        {
            string cmdName = "spBaihoc_Slide_Get";
            return GetList(cmdName);
        }
        public static List<Baihoc_SlideEntity> GetByFK_iBaihocID(Int64 FK_iBaihocID)
		{
			string cmdName = "spBaihoc_Slide_GetByFK_iBaihocID";
			SqlParameter p = new SqlParameter("@FK_iBaihocID", FK_iBaihocID);
			List<Baihoc_SlideEntity> list = GetList(cmdName, p);
			return list;
		}public static List<Baihoc_SlideEntity> GetByFK_iSlideID(Int64 FK_iSlideID)
		{
			string cmdName = "spBaihoc_Slide_GetByFK_iSlideID";
			SqlParameter p = new SqlParameter("@FK_iSlideID", FK_iSlideID);
			List<Baihoc_SlideEntity> list = GetList(cmdName, p);
			return list;
		}
        public static List<Baihoc_SlideEntity> GetByFK_iBaihocIDAndFK_iSlideID(Int64 FK_iBaihocID, Int64 FK_iSlideID)
        {
            string cmdName = "spBaihoc_Slide_GetByFK_iBaihocIDAndFK_iSlideID";
            SqlParameter[] p = new SqlParameter[2];
            p[0] = new SqlParameter("@FK_iBaihocID", FK_iBaihocID);
            p[1] = new SqlParameter("@FK_iSlideID", FK_iSlideID);
            List<Baihoc_SlideEntity> list = GetList(cmdName, p);
            return list;
        }
        public static int Add(Baihoc_SlideEntity entity)
        {
            string cmdName = "spBaihoc_Slide_Insert";
            return Run(cmdName,true,initParams(entity));

        }
        public static bool Edit(Baihoc_SlideEntity entity)
        {
            string cmdName = "spBaihoc_Slide_Update";
            return Run(cmdName,false,initParams(entity))>0;
        }
        public static bool Remove(Int64 PK_iBaihoc_SlideID)
        {
            string cmdName = "spBaihoc_Slide_Delete";
            SqlParameter p = new SqlParameter("@PK_iBaihoc_SlideID", PK_iBaihoc_SlideID);
            return Run(cmdName,false,p)>0;
        }
        #region private
        private static SqlParameter[] initParams(Baihoc_SlideEntity entity)
        {
            SqlParameter[] p = new SqlParameter[4];
			p[0] = new SqlParameter("@PK_iBaihoc_SlideID", entity.PK_iBaihoc_SlideID);
			p[1] = new SqlParameter("@FK_iBaihocID", entity.FK_iBaihocID);
            p[2] = new SqlParameter("@FK_iSlideID", entity.FK_iSlideID);
			p[3] = new SqlParameter("@iSothutu", entity.iSothutu);
            
            return p;
        }
        #endregion
       
    }
}